package com.youtai.common.pojo;

import java.lang.reflect.Field;
import java.util.HashMap;
import java.util.Map;

/**
 * @author wk
 */

public enum StatusCode {
	//通用返回码
	@CodeAnnot("处理失败") ERROR(-1),
	@CodeAnnot("正确处理") OK(1),
	@CodeAnnot("未登录或登录已过期，请重新登录。") RELOAD(1001),
	@CodeAnnot("请输入正确的验证码") failCode(1012),
	@CodeAnnot("该手机号已注册") phoneHasReg(1002),
	@CodeAnnot("token已过期") tokenError(1003),
	@CodeAnnot("该手机号未注册")phoneNeverReg(1004),
	@CodeAnnot("验证码正确") rightCode(1005),
	@CodeAnnot("用户未登录") unLogin(1006),
	@CodeAnnot("没有该产品") noProducts(1007),
	@CodeAnnot("点赞重复") reLike(1008),
	@CodeAnnot("没有该版本") wrongVersion(1010),
	@CodeAnnot("用户名为空") UserNameIsEmpty(1013),
	@CodeAnnot("密码为空") PasswordIsEmpty(1014),
	@CodeAnnot("您的操作过于频繁，请稍后再试") LateTry(1015),
	@CodeAnnot("图片验证码已过期") verifyError(1016),
	@CodeAnnot("应用程序错误") AppError(2),
	@CodeAnnot("数据库错误") DBException(3),
	@CodeAnnot("系统错误") SystemError(4),
	@CodeAnnot("系统繁忙,请稍后再试") SystemBusy(5),
	@CodeAnnot("MD5验证失败") Md5ValidEroor(6),
	@CodeAnnot("参数错误") RequestParamsNotValid(7),
	@CodeAnnot("邮箱格式不正确") EmailValid(8),
	@CodeAnnot("接口错误") ItfcError(10),
	@CodeAnnot("已存在") Exists(11),
	@CodeAnnot("认证失败") attest(1017),
	@CodeAnnot("用户id为空") idIsNull(1018),
	@CodeAnnot("绑定手机失败") bindPhoneError(1018),
	@CodeAnnot("您好，一月只能更换五次") unitePhoneError(1019),
	@CodeAnnot("上传头像失败") uploadHeadImgError(1020),
	@CodeAnnot("修改昵称失败") changeNikNameError(1021),
	@CodeAnnot("code和token都为空") codeError(1022),
	@CodeAnnot("未获取到微信用户信息") memberIsNUll(1023),
	@CodeAnnot("未查询出家人产品信息") familyProductIsNull(1024),
	@CodeAnnot("未查询出家人信息") familyIsNull(1025),
	@CodeAnnot("未查询字典表信息为空") dicIsNull(1026),
	@CodeAnnot("当前微信已解绑") updateMemberError(1027),
	@CodeAnnot("您好，一月只能解绑一次") uniteOpenIdError(1028),
	@CodeAnnot("解绑失败") uniteError(1029),
	@CodeAnnot("验证码过期,请重新获取") expired(1030);





	private final int value;
	private static final Map<String, String> hMap = new HashMap<String, String>();

	// 构造器默认也只能是private, 从而保证构造函数只能在内部使用
	StatusCode(int value) {
		this.value = value;
	}

	static {
		Field[] fields = StatusCode.class.getFields();
		for (Field field : fields) {
			if (field.isAnnotationPresent(CodeAnnot.class)) {
				hMap.put(field.getName(), field.getAnnotation(CodeAnnot.class).value());
			}
		}
	}

	public int getValue() {
		return value;
	}

	public String getDescription() {
		return hMap.get(this.toString());
	}

	public static void main(String[] args) {
		System.out.println(StatusCode.ERROR.getDescription());
		StatusCode.OK.getValue();
	}
}
